/*
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-05-19 10:25:19
 * @LastEditTime: 2022-05-19 10:43:24
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description:
 */
import store from '@/store'
function checkPermission(el, binding) {
  const { value } = binding
  if (value && value instanceof Array) {
    const points = store.getters.userInfo.permission.points
    const hasPermission = points.some(item => value.includes(item))
    if (!hasPermission) {
      el.parentNode && el.parentNode.removeChild(el)
    }
  } else {
    throw new Error('指令需传入一个数组')
  }
}
export default {
  mounted(el, binding) {
    checkPermission(el, binding)
  },
  updated(el, binding) {
    checkPermission(el, binding)
  }
}
